import axios from '@/utils/request';

/**
 * 新增销售出库单
 */
export async function AddSaleoutorder(params) {
    const res = await axios.post('/Saleoutorder/AddSaleoutorder',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 获取销售出库单查询分页列表
 */
 export async function QuerySaleoutorderByCondition(params) {
    const res = await axios.post('/Saleoutorder/QuerySaleoutorderByCondition',params);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 确认选择销售订单
 */
export async function ChooseSaleorder(param) {
    const res = await axios.post('/Saleoutorder/ChooseSaleorder',param);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据销售出库单id获取出库单信息
 */
export async function DeleteSaleoutorder(id) {
    const res = await axios.post('/Saleoutorder/DeleteSaleoutorder?id='+id);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 作废销售出库单
 */
 export async function QuerySaleoutorderById(id) {
    const res = await axios.get('/Saleoutorder/QuerySaleoutorderById/'+id);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 更新销售出库单
 */
 export async function UpdateSaleoutorder(params) {
    const res = await axios.post('/Saleoutorder/UpdateSaleoutorder',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 销售出库单(过账)
 */
export async function AuitSaleoutorder(params) {
    const res = await axios.post('/Saleoutorder/AuitSaleoutorder',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 销售出库单(反过账)
 */
export async function AntiSaleoutorder(id) {
    const res = await axios.post('/Saleoutorder/AntiSaleoutorder?id='+id);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 检测销售单产品明细库存是否充足
 */
export async function CheckStock(params) {
    const res = await axios.post('/Saleoutorder/CheckStock',params);
    if (res.data) {
        return res.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 检测销售出库单发货数量不能大于订单数量
 */
export async function CheckOutQty(params) {
    const res = await axios.post('/Saleoutorder/CheckOutQty',params);
    if (res.data) {
        return res.data;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 打印
 */
export async function PrintSaleOutOrderById(id) {
    const res = await axios.post('/Saleoutorder/PrintSaleOutOrderById?id='+id);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}



